package com.furongji.education.controller.admin;

import com.furongji.common.domain.vo.CourseViewCountVo;
import com.furongji.education.service.CourseService;
import com.furongji.education.service.CourseViewLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@Tag(name = "课程数据统计管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/courses")
public class CourseStatisticsController {

    private final CourseService courseService;

    private final CourseViewLogService courseViewLogService;

    @Operation(summary = "统计新增课程数量")
    @GetMapping("/courseInsertCount/{date}")
    public Integer courseInsertCount(@PathVariable String date) {
        Integer courseInsertCount = courseService.courseInsertCount(date);
        return courseInsertCount;
    }

    @Operation(summary = "统计课程浏览数量")
    @GetMapping("/courseViewCount/{date}")
    public List<CourseViewCountVo> courseViewCount(@PathVariable String date) {
        List<CourseViewCountVo> courseViewCountVos = courseViewLogService.courseViewCount(date);
        return courseViewCountVos;
    }
}
